<template>
  <div>
    <Navsearch  v-show="isShow"></Navsearch>
    <!-- 轮播图 -->
    <van-swipe
      :loop="true"
      :height="160"
      autoplay="3000"
      indicator-color="white"
    >
      <van-swipe-item v-for="(item, index) in imgs" :key="index">
        <img :src="item.img" alt="" class="swiper_img" />
      </van-swipe-item>
    </van-swipe>

    <div class="search">
      <div class="search_first" @click="$router.push('/indexbar')">
        <p>杭州</p>
        <van-icon name="arrow-down" class="icon_onw" />
      </div>
      <p class="search_conter">|</p>
      <div class="search_last" @click="$router.push('/onsearch')">
        <van-icon size="17" name="search" class="icon_two" />
        <input disabled type="text" placeholder="请输入你的关键字" />
      </div>
    </div>
    

    <Conter></Conter>

    <div class="owen">
      <div class="owen_div">
        <p>天天特惠</p>
        <span>上海探店官</span>
        <img src="../../assets/img/wKjFbWLP9d2ASZieAAA_u7nK6V0582.png" alt="" />
      </div>
      <div class="owen_first">
        <p>双旦房券狂欢节</p>
        <span>每满99-20</span>
        <img src="../../assets/img/wKjFbWGohR6AeoluAABMl007yH0944.png" alt="" />
      </div>
      <div class="owen_last">
        <p>新年预约券</p>
        <span>赠代金券不约可退</span>
        <img src="../../assets/img/wKjFbF4CwW-AY-I8AACz9A3h9l4882.png" alt="" />
      </div>
    </div>

    <van-divider :style="{ color: '#2bd483', borderColor: '#79757537' }"
      >省心省内</van-divider
    >

    <div class="writing">
      <p>- 热门产品 -</p>
    </div>

    <Lazy></Lazy>

    <div class="footer">
      <p>购票一点通</p>
      <span>It's easy to buy tickets.</span>
    </div>
  </div>
</template>

<script>
import Conter from "@/components/contern/conter.vue";
import Lazy from "@/components/contern/lazy.vue";
import Navsearch from "@/components/contern/navsearch.vue";
export default {
  data() {
    return {
      border: false,
      imgs: [
        { img: require("../../assets/img/lunbo1.webp") },
        { img: require("../../assets/img/lunbo2.png") },
        { img: require("../../assets/img/lunbo3.jpg") },
        { img: require("../../assets/img/lunbo4.jpg") },
      ],
      isShow: false,
    };
  },
  components: {
    Conter,
    Lazy,
    Navsearch,
  },
  mounted() {
    window.addEventListener("scroll", this.watchscorll);
  },
  methods: {
    watchscorll() {
      // 这是获取当前高度距浏览器高度
      var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
      // var scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
      console.log(scrollTop);
      if (scrollTop >= 161) {
        this.isShow = true
      }
      if(scrollTop < 161){
        this.isShow = false
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.swiper_img {
  width: 100%;
  height: 160px;
}
.search {
  position: absolute;
  width: 355px;
  height: 41px;
  border-radius: 3px;
  top: 140px;
  left: calc((100% - 355px) / 2);
  display: flex;
  padding: 0 15px;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
  background-color: #fff;
  z-index: 1;
  .search_first {
    width: 65px;
    height: 41px;
    display: flex;
    line-height: 41px;
    justify-content: center;
    .icon_onw {
      top: 13px;
    }
  }
  .search_conter {
    line-height: 41px;
    color: #79757537;
  }
  .search_last {
    width: 260px;
    height: 41px;
    line-height: 41px;
    text-align: center;
    .icon_two {
      top: 1px;
    }
  }
}
.van-swipe {
  ::v-deep(.van-swipe__indicators) {
    bottom: 30px;
  }
}
.owen {
  width: 100%;
  height: 110px;
  background-color: #fff;
  padding: 10px;
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  .owen_div {
    width: 113px;
    height: 100%;
    background-color: #fff2e6;
    border-radius: 5px;
    padding-top: 5px;
    overflow: hidden;
    p {
      font-size: 14px;
      text-align: center;
    }
    span {
      display: block;
      text-align: center;
    }
    img {
      width: 90px;
      height: 45px;
      display: block;
      margin: 0 auto;
      margin-top: 7px;
    }
  }
  .owen_first {
    width: 113px;
    height: 100%;
    background-color: #f5f0fb;
    border-radius: 5px;
    padding-top: 5px;
    overflow: hidden;
    p {
      font-size: 14px;
      text-align: center;
    }
    span {
      display: block;
      text-align: center;
    }
    img {
      width: 90px;
      height: 45px;
      display: block;
      margin: 0 auto;
      margin-top: 7px;
    }
  }
  .owen_last {
    width: 113px;
    height: 100%;
    background-color: #ffefec;
    border-radius: 5px;
    padding-top: 5px;
    overflow: hidden;
    p {
      font-size: 14px;
      text-align: center;
    }
    span {
      display: block;
      text-align: center;
    }
    img {
      width: 90px;
      height: 45px;
      display: block;
      margin: 0 auto;
      margin-top: 7px;
    }
  }
}
::v-deep.van-divider {
  height: 40px;
  background-color: #fff;
}
.writing {
  width: 100%;
  height: 20px;
  margin-bottom: 15px;
  p {
    font-size: 14px;
    text-align: center;
  }
}
.footer{
  width: 100%;
  height: 150px;
  p{
    font-size: 16px;
    text-align: center;
    font-family: STSong;
    line-height: 50px;
  }
  span{
    font-size: 16px;
    display: block;
    display: flex;
    justify-content: center;
    font-family: FangSong;
  }
}
</style>
